<!-- components/ListItem.vue -->
<template>
  <div class="list-item" :class="itemClass">
    <!-- 左侧图标区域 -->
    <div v-if="item.icon" class="item-icon">
      <img :src="item.icon" alt="Icon" class="icon-image" />
    </div>

    <!-- 内容区域 -->
    <div class="item-content">
      <div>
        <h3 class="item-title">
          {{ item.nickName || "默认标题" }}
          <img
            class="email"
            src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPng0284b6add4980955f6fe5c744b1054defa5ddedbfc38448430d031cf2cb4d661?noCache=true"
            alt="xin"
          />
        </h3>
        <div class="tags">
          <p v-for="tag in item.tags" key="tag">{{ $t(`list.${tag}`) }}</p>
          <p class="tags-more">···</p>
        </div>
        <div class="country">
          <img
            src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPng253e8f3bee54c6512b84526c37853eee5e4aeb77a92fc60834225039083a7310?noCache=true"
            alt=""
          />
          <span>{{ $t(`list.${item.country}`) }}</span>
        </div>
      </div>
      <div class="data-content">
        <div class="item-meta" v-if="item.meta">
          <div v-for="(value, key) in item.meta" :key="key" class="meta-item">
            <p class="label">{{ $t(`list.${key}`) }}</p>
            <p class="nums">{{ value }}</p>
          </div>
        </div>
      </div>
      <div class="img-content">
        <div class="video-cover">
          <img
            src="https://picsum.photos/40/40?random=1"
            alt="https://picsum.photos/40/40?random=1"
          />
          <img
            class="auto"
            src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPnga0cde2344371df8a8bbc32774eab1283c5febe2348a1e952b21182b54fc9e311?noCache=true"
            alt=""
          />
        </div>
        <img
          src="https://picsum.photos/40/40?random=1"
          alt="https://picsum.photos/40/40?random=1"
          class="img-cover"
        />
        <img
          src="https://picsum.photos/40/40?random=1"
          alt="https://picsum.photos/40/40?random=1"
          class="img-cover"
        />
        <img
          src="https://picsum.photos/40/40?random=1"
          alt="https://picsum.photos/40/40?random=1"
          class="img-cover"
        />
      </div>
      <!-- 额外信息 -->
      <!-- <div class="item-meta" v-if="item.meta">
        <span v-for="(value, key) in item.meta" :key="key" class="meta-item">
          {{ key }}: {{ value }}
        </span>
      </div> -->
    </div>

    <!-- 右侧操作区域 -->
    <div class="item-actions">
      <img
        :src="
          item.msg.like
            ? 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPng3a525035f050f5305f6ad3308a700b4dfddd925b8ff5e2e750489a87849e0527?noCache=true'
            : 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPng57b942a0730ea75e6dfec974310e9d16bd49af488aad0387cf88311bca80c825?noCache=true'
        "
        alt=""
      />
      <img
        :src="
          item.msg.pl
            ? 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPng3b2e1ad52dca082e17ba9dd8a48b9b3a49b74a65254f286ff4350c1f22757ce1?noCache=true'
            : 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPng6befcd3301e701941a1c77f6b7ae79f27aca794d53b208dbfb9ad1b3d3dc7f03?noCache=true'
        "
        alt=""
      />
      <img
        :src="
          item.msg.gk
            ? 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPng8e17373acafd1f26f2a4463e54edc66f922b5484ff042a0d8428841b00f6ef97?noCache=true'
            : 'https://lanhu-oss-2537-2.lanhuapp.com/SketchPngf93c80aab386daffa3fe07467db67f8b428ec589df94843cd40f6f3c7e01b70b?noCache=true'
        "
        alt=""
      />
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits, computed } from "vue"

const props = defineProps({
  item: {
    type: Object,
    required: true,
    default: () => ({}),
  },
  // 自定义类名
  className: {
    type: String,
    default: "",
  },
})

const emit = defineEmits(["action"])

// 处理操作按钮点击
const handleAction = (action) => {
  emit("action", {
    action,
    item: props.item,
  })
}

// 计算类名
const itemClass = computed(() => {
  return ["list-item", props.className].filter(Boolean).join(" ")
})
</script>

<style scoped>
.list-item {
  display: flex;
  align-items: center;
  height: 170px;
  padding: 39px 0;
  /* border-bottom: 1px solid #f0f0f0; */
  transition: background-color 0.2s;
  box-shadow: inset 0px -1px 0px 0px #ececec, inset 0px 1px 0px 0px #ececec;
}

.list-item:hover {
  background-color: #f9f9f9;
}

.item-icon {
  width: 92px;
  height: 92px;
  margin-right: 14px;
  border-radius: 100%;
}

.icon-image {
  width: 100%;
  height: 100%;
  border-radius: 100%;
}

.item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.data-content {
  width: 154px;
  /* height: 112px; */
}

.item-title {
  font-family: SFPro, SFPro;
  font-weight: 800;
  font-size: 17px;
  color: rgba(0, 0, 0, 0.75);
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
}

.item-description {
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  /* display: flex; */
  /* flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #999; */
}

.meta-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.meta-item .label {
  width: 70px;
  height: 22px;
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.45);
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  overflow: hidden;
}
.meta-item .nums {
  min-width: 70px;
  height: 22px;
  font-family: PingFangSC, PingFang SC;
  font-weight: 500;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.85);
  line-height: 22px;
  text-align: right;
  font-style: normal;
  text-transform: none;
}
.meta-item:last-child {
  margin-bottom: 0;
}
.item-actions {
  display: flex;
  /* gap: 8px;
  margin-left: 16px; */
}
.item-actions img {
  width: 22px;
  height: 22px;
  margin-left: 18px;
  cursor: pointer;
}
.action-button {
  padding: 4px 8px;
  background-color: #f0f0f0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.action-button:hover {
  background-color: #e0e0e0;
}

.email {
  width: 16px;
  height: 12px;
}
.tags {
  display: flex;
}
.tags p {
  margin: 8px 8px 6px 0;
  height: 24px;
  border-radius: 6px;
  padding-left: 10px;
  padding-right: 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.63);
  line-height: 24px;
  text-align: left;
  font-style: normal;
  overflow: hidden;
}
.tags-more {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  text-align: center !important;
  font-size: 12px;
  padding-left: 4px !important;
  padding: 0 !important;
  cursor: pointer;
}

.country img {
  width: 14px;
  height: 17px;
  vertical-align: middle;
}

.country span {
  height: 22px;
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.45);
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  margin-left: 3px;
}

.data-content {
  margin-left: 58px;
}

.img-content {
  margin-left: 68px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.video-cover {
  width: 131px;
  height: 90px;
  background: #e8ecf3;
  border-radius: 7px;
  position: relative;
  overflow: hidden;
}
.video-cover img {
  width: 100%;
  height: 100%;
}
.auto {
  position: absolute;
  width: 24px !important;
  height: 24px !important;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.img-cover {
  width: 89px;
  height: 90px;
  background: #e8ecf3;
  border-radius: 7px;
  margin-left: 6px;
}
</style>
